import { http } from "@/utils/http";
import { baseUrlApi } from "./utils";

/**
 * 飞书认证回调接口参数
 */
interface FsAppIdType {
  code: number;
  message: string | null;
  data: string;
}

interface FsAuthType {
  code: number;
  message: string | null;
  data: {
    access_token: string | null;
    name: string;
    en_name: string;
    avatar_url: string;
    avatar_thumb: string;
    avatar_middle: string;
    avatar_big: string;
    open_id: string;
    union_id: string;
    email: string;
    enterprise_email: string;
    user_id: string;
    mobile: string;
    tenant_key: string;
    employee_no: string;
  };
}

/** 获取飞书的应用ID*/
export const getFsAppId = async () => {
  return http.request<FsAppIdType>("get", baseUrlApi("auth/app-id"));
};
/** 飞书认证*/
export const getFsAuth = async (params?: Record<string, any>) => {
  return http.request<FsAuthType>("get", baseUrlApi("auth/callback-ex"), {
    params
  });
};
